package com.ssuu.ssuusnow.project.manage.role.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ssuu.ssuusnow.model.result.ResultVo;
import com.ssuu.ssuusnow.project.manage.role.entity.Role;
import com.ssuu.ssuusnow.project.manage.role.service.impl.RoleServiceImpl;
import com.ssuu.ssuusnow.project.manage.user.entity.User;
import com.ssuu.ssuusnow.project.manage.user.service.impl.UserServiceImpl;
import com.ssuu.ssuusnow.utils.log.LogPrint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * <p>
 * 角色 前端控制器
 * </p>
 *
 * @author sun
 * @since 2023-06-14
 */
@RestController
@CrossOrigin
@RequestMapping("/role")
@Api(value = "角色", tags = "角色")
@ApiSupport(author = "孙")
public class RoleController {
    @Resource
    RoleServiceImpl roleService;
    @PostMapping("/add")
    @LogPrint("新增角色")
    @ApiOperation(value = "新增角色",notes = "新增角色")
    @ApiOperationSupport(ignoreParameters = {"id","createTime","updateTime","updateby","isdel"})
    public ResultVo add(@RequestBody Role u) {
        return new ResultVo(roleService.AddTo(u));
    }
    @PutMapping("/update")
    @LogPrint("修改角色")
    @ApiOperation(value = "修改角色",notes = "修改角色")
    @ApiOperationSupport(ignoreParameters = {"createTime","updateTime","updateby","isdel"})
    public ResultVo update(@RequestBody Role u) {
        return new ResultVo(roleService.UpdateTo(u));
    }
    @DeleteMapping("/del/{id}")
    @LogPrint("删除角色")
    @ApiOperation(value = "删除角色",notes = "删除角色")
    public ResultVo del(@PathVariable(value="id") Long id) {
        return new ResultVo(roleService.DelTo(id));
    }
    @GetMapping("/getlist")
    @LogPrint("查询角色")
    @ApiOperation(value = "查询角色",notes = "查询角色")
    @ApiOperationSupport(ignoreParameters = {"id","createTime","updateTime","updateby","isdel"})
    public ResultVo get(Role u) {
        return new ResultVo(roleService.listTo(u));
    }
}
